package com.amex.uam.model;

import com.amex.uam.util.Utils;

public class Message {

	/* ************************
	 * Response Codes 
	 * ***********************/
	public static final int OK = 200;
	public static final int ERROR = 500;
	public static final int ERROR_SUBID = 501;
	public static final int ERROR_PARAM = 502;

	private int status;
	private Object data;

	
	public static Message newOK(){
		return new Message(Message.OK);
	}
	public static Message newError(){
		return new Message(Message.ERROR);
	}
	public static Message newError(String errorMessage){
		return new Message(Message.ERROR, errorMessage);
	}
	
	public Message() {
		status = OK;
	}
	public Message(int status) {
		this.setStatus(status);
	}
	
	public Message(int status, Object data) {
		this.setStatus(status);
		this.setData(data);
	}
	
	public int getStatus() {
		return status;
	}

	public Message setStatus(int status) {
		this.status = status;
		return this;
	}

	public Object getData() {
		return data;
	}

	public Message setData(Object data) {
		this.data = data;
		return this;
	}

	public String toJSON() {
		return Utils.toJson(this);
	}
	
}
